package com.haidechizi.fastadmin.modules.code.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.haidechizi.fastadmin.common.page.PageDto;
import com.haidechizi.fastadmin.common.utils.ObjectUtils;
import com.haidechizi.fastadmin.common.utils.PageInfo;
import com.haidechizi.fastadmin.modules.code.entity.MessageCodeConfig;
import com.haidechizi.fastadmin.modules.code.dao.MessageCodeConfigDao;
import com.haidechizi.fastadmin.modules.code.service.MessageCodeConfigService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import com.haidechizi.fastadmin.modules.sys.service.SysDictService;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * 静态资源Service
 * @author wangdejun
 * @version 2020-11-05
 */
@Service
@Transactional(readOnly = true)
public class MessageCodeConfigServiceImpl extends ServiceImpl<MessageCodeConfigDao, MessageCodeConfig> implements MessageCodeConfigService {

	@Autowired
	private SysDictService sysDictService;


	/**
	 * 分页查询
	 *
	 * @param pageDto
	 * @param messageCodeConfig
	 * @return
	 */
	@Override
    public PageInfo findPage(PageDto pageDto, MessageCodeConfig messageCodeConfig) {
        Page<MessageCodeConfig> page = this.selectPage(
                pageDto.cover2Page(),
                new EntityWrapper<MessageCodeConfig>()
						.eq(ObjectUtils.isNotEmpty(messageCodeConfig.getType()), "type", messageCodeConfig.getType())
						.eq(ObjectUtils.isNotEmpty(messageCodeConfig.getTranslateType()), "translate_type", messageCodeConfig.getTranslateType())
        );
		List<MessageCodeConfig> messageCodeConfigList = page.getRecords();
		for (MessageCodeConfig messageCodeConfig1: messageCodeConfigList) {

			messageCodeConfig1.setLanguageType(sysDictService.coverList2Labels(messageCodeConfig1.getLanguageType(),"language"));

		}
        return new PageInfo(page);
    }
	
}